package jeons.common.util;

import org.springframework.mail.*;
import org.springframework.stereotype.Service;
@Service
public class SimpleMailService {

	 

	 private MailSender mailSender;

	 

	 public void setMailSender(MailSender mailSender) {
	  this.mailSender = mailSender;
	 }
	 
	 public boolean sendMail(String username,String userpassword,String useremail){
		 System.out.println("MailService : "+useremail);
	  SimpleMailMessage simpleMsg = new SimpleMailMessage();
	  simpleMsg.setSubject("jEON 쇼핑몰 입니다.");
	  simpleMsg.setText("안녕하세요 \n 고객님의 비밀번호는 \n"+username+"님의 비밀번호는 : "+userpassword+"입니다.");
	  simpleMsg.setFrom("amok8787@gmail.com");
	  simpleMsg.setTo(new String[]{"amok87@naver.com"});
	  try{
	   mailSender.send(simpleMsg);
	   System.out.println("메일 보내기 성공");
	   return true;
	  }catch(MailException me){
	   System.err.println("메일보내기 오류");
	   me.printStackTrace();
	  }
	  return false;
	 }
	}